package main

import (
	"context"
	"demo-2025/demo01"
	"fmt"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func main() {
	demo01.Enter()
	// 等待中断信号以优雅地关闭服务器（设置 5 秒的超时时间）
	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT)
	sig := <-signalChan
	fmt.Println("Get Signal:" + sig.String())
	fmt.Println("Shutdown Server ...")

	_, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()
	fmt.Println("Server exiting")
}
